package demo1;

//接口中的成员变量默认是public static final
//成员方法默认是public abstract
interface IShape{
    int a = 10;
    void draw();

    //Java8开始，允许在接口中定义一个default方法，可以具体实现
    default public void func(){
        System.out.println("func()");
    }
    //接口中，如果是static修饰的方法，也可以具体实现
    public static void func2(){
        System.out.println("func2()");
    }
}
class Rect implements IShape{
    public void draw(){
        System.out.println("Rect");
    }
}

class Flower implements IShape{
    public void draw(){
        System.out.println("Flower");
    }
}

public class Test {
    public void  ShapeMap(IShape ishape){
        ishape.draw();
    }
    public static void main(String[] args) {
        //接口不能被实例化
//        IShape shape = new IShape() ;

        IShape ishape1 = new Rect();
        IShape ishape2 = new Flower();
        Test t = new Test();
        t.ShapeMap(ishape1);
        t.ShapeMap(ishape2);
    }
}
